﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:viewmodel="clr-namespace:DDU.ViewModel;assembly=DDU.ViewModel"
    xmlns:UX="clr-namespace:DDU.UX;assembly=DDU.UX"
    xmlns:Converters="clr-namespace:DDU.Converters;assembly=DDU.Converters" 
    x:Class="DDU.Curriculum.Views.SemesterView"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False">

    <phone:PhoneApplicationPage.Resources>
        <Converters:EnumTranslateConverter x:Key="EnumTranslateConverter"/>
        <Converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot contains the root grid where all other page content is placed-->
    <Grid x:Name="LayoutRoot">
        <Grid.Background>
            <ImageBrush Stretch="Fill" ImageSource="/Assets/back.png"/>
        </Grid.Background>
        <Grid.DataContext>
            <viewmodel:SemesterViewModel/>
        </Grid.DataContext>
        <controls:Panorama>
            <controls:Panorama.Title>
                <Image Source="{Binding LogoPath}" Margin="12,76,0,0"/>
            </controls:Panorama.Title>

            <!--Panorama item one-->
            <controls:PanoramaItem Header="{StaticResource IDS_SEMESTER_TITLE}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>
                    <ListBox ItemsSource="{Binding ItemsOfSemesters}" 
                             SelectedItem="{Binding SelectedSemester, Mode=TwoWay}">
                        <ListBox.ItemContainerStyle>
                            <Style TargetType="ListBoxItem">
                                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="ListBoxItem">
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition/>
                                                    <RowDefinition Height="2"/>
                                                </Grid.RowDefinitions>

                                                <StackPanel Margin="0,12">
                                                    <TextBlock Style="{StaticResource PhoneTextTitle2Style}">
														<Run Text="{Binding EducationLevel, Converter={StaticResource EnumTranslateConverter}}"/>
														<Run Text=" "/>
														<Run Text="{Binding Grade, Converter={StaticResource EnumTranslateConverter}}"/>
														<Run Text=" "/>
														<Run Text="{Binding Term, Converter={StaticResource EnumTranslateConverter}}"/>
                                                    </TextBlock>
                                                    <TextBlock Style="{StaticResource PhoneTextSubtleStyle}">
														<Run Text="{Binding StartTime, StringFormat=\{0:yyyy-MM-dd\}}"/>
														<Run Text=" - "/>
														<Run Text="{Binding EndTime, StringFormat=\{0:yyyy-MM-dd\}}"/>
                                                    </TextBlock>
                                                </StackPanel>

                                                <Rectangle Fill="{StaticResource PhoneAccentBrush}" 
                                                           Grid.Row="1" 
                                                           Margin="12,0" 
                                                           Visibility="{Binding IsSelected, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource TemplatedParent}}"/>
                                            </Grid>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ListBox.ItemContainerStyle>
                    </ListBox>

                    <UX:UXPathButton Margin="0,-82,0,0" 
                                     Padding="13" 
                                     IconPath="{Binding Mode=OneWay, Source={StaticResource PATH_ICON_CLOSE}}" 
                                     Angle="45" 
                                     Uri="/Views/SemesterAddView.xaml" 
                                     HorizontalAlignment="Right" 
                                     VerticalAlignment="Top" />

                    <Grid Grid.Row="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>

                        <UX:UXIconTextButton Margin="12" 
                                             HorizontalAlignment="Center" 
                                             Content="{StaticResource IDS_COMMON_DELETE}" Grid.Row="1" 
                                             Path="{StaticResource PATH_ICON_DELETE}" 
                                             Command="{Binding DeleteCommand, Mode=OneWay}"/>
                        <UX:UXIconTextButtonWithParam Margin="12" 
                                                      HorizontalAlignment="Center" 
                                                      Content="{StaticResource IDS_COMMON_EDIT}" 
                                                      Grid.Row="1" 
                                                      Path="{StaticResource PATH_ICON_EDIT}" 
                                                      Grid.Column="1" 
                                                      ParameterName="guid" 
                                                      ParameterValue="{Binding SelectedSemester.Guid}" 
                                                      Uri="/Views/SemesterEditView.xaml" />
                    </Grid>                    
                </Grid>
            </controls:PanoramaItem>

            <!--Panorama item two-->
            <controls:PanoramaItem Header="{StaticResource IDS_SEMESTER_COURSE}">
                <Grid>
                    <ListBox ItemsSource="{Binding CoursesOfSemester}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Style="{StaticResource PhoneTextTitle2Style}" Text="{Binding Name}" Margin="12"/>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </Grid>
            </controls:PanoramaItem>
        </controls:Panorama>
    </Grid>

</phone:PhoneApplicationPage>